<template>
  <div>
    <div class="game_header">
      <img class="game_icon" :src="gameinfo.gameicon" alt="">
      <div class="game_info">
        <!-- 1.游戏名 -->
        <div class="game_name_box">
          <span class="game_name">{{gameinfo.gamename}}</span>
          <!-- 折扣 -->
          <span class="game_flash" v-show="gameinfo.is_flash">{{flashDiscount}}折</span>
        </div>
        <!-- 2.游戏类型 -->
        <div class="genre_str">{{gameinfo.genre_str}}</div>
        <!-- 3.游戏大小和一句话简介 -->
        <div class="game_summary_box">
          <div v-show="gameinfo.client_size" class="client_size">{{gameinfo.client_size}}M</div>
          <div v-show="gameinfo.client_size"> | </div>
          <div class="game_summary">{{gameinfo.game_summary}}</div>
        </div>
        <!-- 4.BT游戏显示labels -->
        <div class="label_box" v-if="gameinfo.game_type === '1'">
          <span 
            v-for="(item, index) in gameinfo.game_labels" 
            :key="index" 
            :style="{background: item.bgcolor + '4d',color: item.bgcolor}" 
            class="game_label">
            {{item.label_name}}
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    gameinfo: {
      type: Object,
      default() {
        return {}
      }
    },
  },
  computed: {
    flashDiscount() {
      if(this.gameinfo.is_flash === 1) {
        var count = this.gameinfo.flash_discount
        var str = parseFloat((100 - count) / 10)
      }
      return str
    }
  },
}
</script>

<style lang="less" scoped>
.game_header {
  box-sizing: border-box;
  width: 10rem;
  height: 2.506667rem;
  padding: .4rem .426667rem;
  background: #fff;
  font-size: .266667rem;
  display: flex;
  align-items: center;
  overflow: hidden;
  .game_icon {
    margin-right: .293333rem;
    width: 1.706667rem;
    height: 1.706667rem;
    border-radius: .4rem;
    overflow: hidden;
  }
  .game_info {
    width: 7.146667rem;
    height: 1.706667rem;
    color: #999999;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    .game_name {
      font-size: .346667rem;
      font-weight: bold;
      color: #222222;
    }
    .game_flash {
      display: inline-block;
      font-size: .32rem;
      height: .4rem;
      line-height: .4rem;
      padding: 0 .2rem;
      border-radius: .2rem;
      color: #fff;
      background: linear-gradient(134deg, #FFAC58 0%, #FFAB57 0%, #FF4600 100%);
      margin-left: .133333rem;
    }
    .genre_str {
      font-size: .293333rem;
      font-weight: 500;
      color: #999999;
    }
    .game_summary_box {
      display: flex;
      .client_size {
        display: inline-block;
        line-height: .4rem;
        font-size: .293333rem;
        font-weight: 500;
        color: #999999;
      }
      .game_summary {
        line-height: .4rem;
        display: inline-block;
        font-size: .293333rem;
        font-weight: 500;
        color: #999999;
        width: 5.8rem;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .label_box {
      font-size: .266667rem;
      height: .36rem;
      display: flex;
      flex-wrap: nowrap;
      width: 13.333333rem;
      .game_label {
        font-size: .266667rem;
        display: inline-block;
        margin-right: .08rem;
        padding: .026667rem;
        height: .36rem;
        line-height: .36rem;
      }
    }
  }
}
</style>